<%@ Page Language="VB" Theme="default" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="MembershipDetails.aspx.vb" Inherits="Secure_WebAdmin_MembershipDetails" Title="Memebership Detail" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <div>
        <table id="Table1" border="0" cellpadding="2" cellspacing="2" width="100%">
            <tr>
                <td colspan="3">
                    <strong><font size="2">MEMBERSHIP DETAILS</font></strong>
                </td>
                <td colspan="1" align="right">
                    <asp:HyperLink ID="hlBack" runat="server" NavigateUrl="MembershipManager.aspx" ForeColor="Blue">Back</asp:HyperLink></td>
            </tr>
            <tr>
                <td colspan="4">
                    <hr size="1" width="100%" />
                </td>
            </tr>
            <tr>
                <td rowspan="2" valign="top" width="15">
                </td>
                <td rowspan="2" valign="top" width="360">
                    <asp:DetailsView ID="dvUser" runat="server" AutoGenerateRows="False" DataKeyNames="UserName"
                        DataSourceID="odsMembership" Height="50px" Width="100%" AutoGenerateEditButton="True">
                        <Fields>
                            <asp:BoundField DataField="UserName" HeaderText="UserName" ReadOnly="True" SortExpression="UserName" />
                            <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                            <asp:CheckBoxField DataField="IsApproved" HeaderText="Is Approved" SortExpression="IsApproved" />
                            <asp:TemplateField HeaderText="Comment" SortExpression="Comment">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Comment") %>' TextMode="MultiLine" Width="96%"></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Comment") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="CreationDate" HeaderText="Creation Date" ReadOnly="True"
                                SortExpression="CreationDate" />
                            <asp:BoundField DataField="LastLoginDate" HeaderText="Last Login" SortExpression="LastLoginDate" ReadOnly="True" />
                            <asp:BoundField DataField="LastActivityDate" HeaderText="Last Activity" SortExpression="LastActivityDate" ReadOnly="True" />
                            <asp:CheckBoxField DataField="IsLockedOut" HeaderText="Is LockedOut" SortExpression="IsLockedOut"
                                Text="(Unlock only)" />
                            <asp:BoundField DataField="LastLockoutDate" HeaderText="Last Lockout" ReadOnly="True"
                                SortExpression="LastLockoutDate" />
                            <asp:BoundField DataField="LastPasswordChangedDate" HeaderText="Last Password Changed"
                                ReadOnly="True" SortExpression="LastPasswordChangedDate" />
                        </Fields>
                    </asp:DetailsView>
                    <asp:ObjectDataSource ID="odsMembership" runat="server" SelectMethod="GetMember"
                        TypeName="DotNetPM.Business.MembershipsAndRoles.MembershipODS" UpdateMethod="UpdateMember">
                        <SelectParameters>
                            <asp:SessionParameter Name="userName" SessionField="core_UserName" Type="String" />
                        </SelectParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="userName" Type="String" />
                            <asp:Parameter Name="email" Type="String" />
                            <asp:Parameter Name="comment" Type="String" />
                            <asp:Parameter Name="isApproved" Type="Boolean" />
                            <asp:Parameter Name="isLockedOut" Type="Boolean" />
                        </UpdateParameters>
                    </asp:ObjectDataSource>
                </td>
                <td valign="top" style="height:10px"  colspan="2">
                    <asp:CheckBox ID="cbShowOnlyAssignedRoles" runat="server" AutoPostBack="True" Text="Show Assigned Roles Only" /><br />
                    <br />
                    <asp:GridView ID="gvRoles" runat="server" AutoGenerateColumns="False" DataSourceID="odsRoles" AllowPaging="True">
                        <Columns>
                            <asp:TemplateField SortExpression="IsUserInRole">
                                <ItemTemplate>
                                    <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("IsUserInRole") %>' 
                                    oncheckedchanged="RoleAssigning" AutoPostBack=true  />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Role Name" SortExpression="RoleName">
                                <ItemTemplate>
                                    <asp:Label ID="RoleName" runat="server" Text='<%# Bind("RoleName") %>'></asp:Label>
                                </ItemTemplate>
                                <ControlStyle Width="200px" />
                                <ItemStyle Width="200px" />
                            </asp:TemplateField>
                            <asp:BoundField DataField="NumberOfUsersInRole" HeaderText="# Users in Role"
                                SortExpression="NumberOfUsersInRole" />
                        </Columns>
                    </asp:GridView>
                    <asp:ObjectDataSource ID="odsRoles" runat="server" DeleteMethod="DeleteRole"
                        InsertMethod="InsertRole" OldValuesParameterFormatString="original_{0}" SelectMethod="GetRoles"
                        TypeName="DotNetPM.Business.MembershipsAndRoles.RoleODS">
                        <DeleteParameters>
                            <asp:Parameter Name="roleName" Type="String" />
                        </DeleteParameters>
                        <SelectParameters>
                            <asp:ControlParameter ControlID="dvUser" Name="userName" PropertyName="SelectedValue"
                                Type="String" />
                            <asp:ControlParameter ControlID="cbShowOnlyAssignedRoles" Name="showOnlyAssignedRoles"
                                PropertyName="Checked" Type="Boolean" />
                        </SelectParameters>
                        <InsertParameters>
                            <asp:Parameter Name="roleName" Type="String" />
                        </InsertParameters>
                    </asp:ObjectDataSource>
                </td>
            </tr>
        </table>
    </div>
    </asp:Content>
